package com.example.flower_shop.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
import java.math.BigDecimal;

@Data
@Entity
@Table(name = "products")
@EqualsAndHashCode(callSuper = true)
public class Product extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id", nullable = false)
    @JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
    private Category category;

    @Column(name = "name", nullable = false, columnDefinition = "nvarchar(100)")
    private String name;

    @Column(name = "description", columnDefinition = "nvarchar(500)")
    private String description;

    @Column(name = "price", nullable = false)
    private BigDecimal price;

    @Column(name = "stock", nullable = false)
    private Integer stock;

    @Column(name = "image_url", columnDefinition = "nvarchar(255)")
    private String imageUrl;

    @Column(name = "status")
    private Integer status;

    @Column(name = "is_carousel")
    private Boolean isCarousel = false;

    @Column(name = "is_recommended")
    private Boolean isRecommended = false;

    @Column(name = "is_hot")
    private Boolean isHot = false;

    @Column(name = "sales_count")
    private Integer salesCount = 0;

    @Column(name = "carousel_sort")
    private Integer carouselSort = 0;

    @Column(name = "recommend_sort")
    private Integer recommendSort = 0;
}